import React from 'react'
import { Route, Switch, routerRedux } from 'dva/router'
import { LocaleProvider } from 'antd';
import zhCN from 'antd/lib/locale-provider/zh_CN'
import { getRouterData } from '@/custom/router'
import PrivateRoute from './custom/PrivateRoute'

const { ConnectedRouter } = routerRedux
function RouterConfig({ history, app}) {
  const routerData = getRouterData(app)
  const LoginLayout = routerData['/login'].component
  const BaseLayout = routerData['/'].component
  return (
    <LocaleProvider locale={zhCN}>
      <ConnectedRouter history={history}>
        <Switch>
          <Route path="/login" component={LoginLayout}/>
          <PrivateRoute
            authority={['admin', 'user']}
            render={props => {
              console.log('11111', props)
              let t = { routerData }
              return <BaseLayout {...props}/>
            }}
            redirect="/login"
            path="/"
          />
        </Switch>
      </ConnectedRouter>
    </LocaleProvider>
  );
}

export default RouterConfig


